<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:layout name="Default" />
<!-- /**  
 * @Author: Wang Hongbin  
 * @Email:   wanghongbin@ngoos.org  
 * @Date:   2018-06-21 14:28:22  
 * @Last Modified by:   Wang Hongbin  
 * @Last Modified time: 2018-06-21 14:28:22  
 */ -->  
<f:section name="main">
	<f:flashMessages />
	<div class="panel panel-default">
	    <div class="panel-body">
	         <fieldset>
	             <legend>二维码打印</legend>
	             <!--startprint-->
             	 <div class="text-center" id="picOutDiv">
             	 	<br/>
	             	<img src="uploads/tx_users/{user.qrcode}" width="300px" height="300px"/><br/>
	             	{user.community.name}&nbsp;&nbsp;&nbsp;{user.name}
	             </div>
	             <!--endprint-->
	             <div class="horizontal-space"></div>
	             <div class="form-buttons">
					<a href="javascript:;" onclick="doPrint()" class="btn btn-info">打印</a>
					<f:link.action action="list" class="btn btn-default">返回列表</f:link.action>
	             </div>
	         </fieldset>
	    </div>
	</div>
	<script>
		//指定部分内容打印
		function doPrint(){
			var headHtml = "<head><style type='text/css' media='print'> @page{ size:  auto;   /* auto is the initial value */margin: 0mm;  /* this affects the margin in the printer settings */}html{/*background-color: #FFFFFF; */margin: 0px;  /* this affects the margin on the html before sending to printer */}</style></head><body>"
	        var bottHtml = "</body>";
			var bdhtml = window.document.body.innerHTML;  
		  	var sprnstr = "<!--startprint-->";    //用于截断字符串的内容，截取到指定的图片内容了
		  	var eprnstr = "<!--endprint-->";  
		  	var prnhtml = headHtml+bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);  
		    prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr))+bottHtml;  
			window.document.body.innerHTML = prnhtml;  
			if(getExplorer() == "IE"){
				pagesetup_null();  
			}
		    window.print();  
		    window.document.body.innerHTML=bdhtml; //还原 原有页面内容; 
		}

	//获取浏览器类型
	function getExplorer(){
	    var explorer = window.navigator.userAgent;  
	    //ie   
	    if (explorer.indexOf("MSIE") >= 0) {  
	        return "IE";  
	    }  
	        //firefox   
	    else if (explorer.indexOf("Firefox") >= 0) {  
	        return "Firefox";  
	    }  
	        //Chrome  
	    else if (explorer.indexOf("Chrome") >= 0) {  
	        return "Chrome";  
	    }  
	        //Opera  
	    else if (explorer.indexOf("Opera") >= 0) {  
	        return "Opera";  
	    }  
	        //Safari  
	    else if (explorer.indexOf("Safari") >= 0) {  
	        return "Safari";  
	    }  
	}  

	//IE设置去除页眉页脚  
	function pagesetup_null(){
		/* var hkey_path;
		hkey_path = "HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
		try {
		   var RegWsh = new ActiveXObject("WScript.Shell");
		   RegWsh.RegWrite(hkey_path + "header", "");
		   RegWsh.RegWrite(hkey_path + "footer", "");
		} catch (e) {
		} */
	    var hkey_root, hkey_path, hkey_key;  
	    hkey_root = "HKEY_CURRENT_USER";  
	    hkey_path = "\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";  
	    try {
	        var RegWsh = new ActiveXObject("WScript.Shell");  
	        hkey_key = "header";  
	        RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "");  
	        hkey_key = "footer";  
	        RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "");  
	    } catch(e){}
	}  
	</script>
</f:section>
</html>